package calvin.study.rabbitmq.config.mq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 死信交换机、队列、绑定关系
 * 
 * @author wh
 *
 */
@Configuration
public class DeadLetterMqConfig {

	// 声明死信交换机
	@Bean
	public DirectExchange deadLetterDirectExchange() {
		return new DirectExchange("dead_letter_direct_exchange", true, false);
	}

	// 声明死信队列
	@Bean
	public Queue deadLetterQueue() {
		return new Queue("dead_letter_queue1", true);
	}
	

	//死信交换机、队列绑定
	@Bean
	public Binding deadLetterBingds() {
		return BindingBuilder.bind(deadLetterQueue()).to(deadLetterDirectExchange()).with("deadletter");
	}
}
